package com.bj.disc.ui.login.vm

import androidx.lifecycle.MutableLiveData
import com.ai3d.rfid.R
import com.ai3d.rfid.base.vm.BaseViewModel
import com.ai3d.rfid.common.log.Logcat
import com.ai3d.rfid.common.proxy.ToastProxy
import com.ai3d.rfid.ext.request
import com.ai3d.rfid.network.proxy.NetworkProxy
import com.bj.disc.ui.login.bean.LoginReq
import com.bj.disc.ui.login.bean.LoginResp
import com.blankj.utilcode.util.ActivityUtils

/**
 * @ProjectName : Kolb
 * @Author : weijinsong
 * @Time : 2023/1/5 9:56
 * @Description : 登录
 */
class LoginViewModel : BaseViewModel() {
    private val TAG = "LoginViewModel"
    val account = MutableLiveData("")
    var password = MutableLiveData("")

    var loginResp = MutableLiveData<LoginResp>()
    var isShowPwd = MutableLiveData(false)

    fun login(loginReq: LoginReq) {
        request({ NetworkProxy.accountApi.login(loginReq) }, {
            loginResp.value = it
        }, {
            ToastProxy.showShort(it.errorMsg)
            Logcat.d(TAG, "sendVerifyCode errorMsg : ${it.errorMsg}")
        }, true, ActivityUtils.getTopActivity().resources.getString(R.string.login_in))
    }
}